export function lrc2Json(lrc) {
  let arr = lrc.split('\n');
  if (arr[0].includes('by')) {
    arr.shift();
  }
  let timeReg = /^\[.*\]/;
  let json = [];
  if (timeReg.test(arr[0])) {
    arr.forEach((item) => {
      if (item.length > 0) {
        let t = item.match(timeReg)[0];
        // console.log(t.length);
        let time = t.substr(1, 8);
        let minute = time.substr(0, 2);
        let second = time.substr(3, 2);
        let ms = time.substr(6, 2);
        json.push({
          time,
          ms:
            parseInt(minute) * 60 * 1000 +
            parseInt(second) * 1000 +
            parseInt(ms) * 10,
          content: item.substr(t.length),
        });
      }
    });
  } else {
    arr.forEach((item) => {
      if (item.length > 0) {
        json.push({
          time: '00.00.00',
          ms: 0,
          content: item,
        });
      }
    });
  }
  // console.log(json);
  return json;
}
